package com.campus_activity.campus_activity.handler.exception;

import com.campus_activity.campus_activity.common.R;
import com.campus_activity.campus_activity.exception.BusinessException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 业务逻辑异常处理器
 * @author icyrain11
 * @version 1.8
 */
@RestControllerAdvice
@Slf4j
public class BusinessExceptionHandler {

    @ExceptionHandler(BusinessException.class)
    public R<?> businessExceptionHandler(BusinessException e) {
        log.error("businessException: " + e.getMessage(), e);
        return R.fail(e.getCode(), e.getMessage());
    }


}
